//1.  [...new Set(arr)]

const arr1  = [1,2,3,2,1];
const arr2 = [3,2,4,5,4];

//对数组进行一个去重;
let set1 = [... new Set(arr1)];
let set2 = [... new Set(arr2)];

console.log(set1);
console.log(set2);

//求两个数组之间的交集;

for(let i = 0; i < set1.length; i++){
       //console.log(set2.indexOf(set1[i]));
        let flag = set2.indexOf(set1[i]);
        if(flag == -1){
             //console.log(flag);
             continue;
        }
        console.log(set2[flag]);

}


//求两个数组之间的差集;


var minus = set1.filter(function(v){ return set2.indexOf(v) == -1 });
console.log(minus)